﻿
@{
    ViewBag.Title = "资金明细";
}
@section CSS{

}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            @ViewBag.TypeName
            <small>记录</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">财务管理</a></li>
            <li><a href="/finance/index">财务明细</a></li>
            <li class="active"> @ViewBag.TypeName 记录</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <!-- /.col -->
            <!-- fix for small devices only -->
            <div class="clearfix visible-sm-block"></div>
            <div class="col-md-6">
                <div class="info-box">
                    <span class="info-box-icon bg-aqua"><i class="ion ion-ios-locked-outline"></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">冻结资金</span>
                        <span class="info-box-number">￥@(Model == null ? 0 : Model.balance_freeze.ToString("f2"))<small>元</small></span>
                        @if (ViewBag.type == 2)
                        {
                            <a href="/Finance/FinanceReturn/1">查看记录>></a>
                        }
                    </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>
            <div class="col-md-6 ">
                <div class="info-box">
                    <span class="info-box-icon bg-red"><i class="fa ion-ios-bell-outline "></i></span>

                    <div class="info-box-content">
                        <span class="info-box-text">欠款金额</span>
                        <span class="info-box-number">￥@(Model == null ? 0 : Model.balance_due.ToString("f2"))<small>元</small></span>
                        @if (ViewBag.type == 1)
                        {
                        <a href="/Finance/FinanceReturn/2">查看账单>></a>
                        }
                        </div>
                    <!-- /.info-box-content -->
                </div>
                <!-- /.info-box -->
            </div>

        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header my_search">
                        <input type="text" style="width:120px;" class="form-control pull-left" id="return_startTime" placeholder="交易日期-起">
                        <span style="line-height:30px;">至</span>
                        <input type="text" style="width:120px;" class="form-control pull-left" id="return_endTime" placeholder="交易日期-止">
                        <button type="button" class="btn btn-default " id="return_btnSearch"><i class="fa fa-search"></i> 搜索</button>
                    </div>
                    <div class="box-body">
                        <table id="DataList2" class="table table-bordered table-striped table-hover ">
                            <thead>
                                <tr>
                                    <th>交易时间</th>
                                    <th>流水编号</th>
                                    <th>订单编号ID</th>
                                    <th>交易类型</th>
                                    <th>交易金额(元)</th>
                                    <th width="200">备注</th>
                                    <th>查看</th>
                                </tr>
                            </thead>
                            <tbody> </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- /.content-wrapper -->
@section JS{
    <script>
        function FinanceReturnList(type) {
            u_table2.fnDestroy();
            GenerateTable2(type);
        }
        $(function () {
            //初始化表格
            GenerateTable2();
            //鼠标移动到该行变色
            $('.table-hover tbody').on('click', 'tr', function () {
                if ($(this).hasClass('selected')) {
                    $(this).removeClass('selected');
                }
                else {
                    u_table.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                }
            });
            //搜索事件
            $("#return_btnSearch").on("click", function () {
                var classSelect = $("#classSelect").val();
                var datemin = $('#return_startTime').val();
                var datemax = $("#return_endTime").val();
                if ((datemin == null && datemax != null) || (datemin != null && datemax == null)) {
                    layer.msg('请把时间填充完整!', { icon: 1, time: 1000 });
                }
                else {
                    u_table2.fnDestroy();
                    GenerateTable2();
                }
            });

            $('#return_startTime').datepicker({
                autoclose: true
            });

            $('#return_endTime').datepicker({
                autoclose: true
            });
        });
        //冻结欠款
        function GenerateTable2(type) {
            u_table2 = $('#DataList2').dataTable({
                "lengthChange": false,
                "searching": false,
                "ordering": false,
                "iDisplayLength": 10,
                "bProcessing": true,
                "bServerSide": true,
                "fnServerParams": function (aoData) {
                    var datemin = $('#return_startTime').val();
                    var datemax = $("#return_endTime").val();
                    aoData.push(
                        { "name": "dateMin", "value": datemin },
                        { "name": "dateMax", "value": datemax },
                        { "name": "type", "value": @ViewBag.type }
                    );
                },
                "sAjaxSource": "/finance/FinanceReturnList",
                "aoColumns": [
                    {
                        "mDataProp": 'add_time', "mRender": function (data, type, full) {
                            return moment(data).format("YYYY-MM-DD HH:mm:ss");
                        }
                    },
                    //{ "mDataProp": 'id' },
                    { "mDataProp": 'return_no' },
                    { "mDataProp": 'order_no' },
                     {
                         "mDataProp": 'type', "mRender": function (data, type, full) {
                             return data == 1 ? "退款冻结" : "退款欠款";
                         }
                     },
                    {
                        "mDataProp": 'money', "mRender": function (data, type, full) {
                            return "-" + data;
                        }
                    },
                    { "mDataProp": 'remark' }
                    , {
                        "mDataProp": 'id', "mRender": function (data, type, full) {
                            return ' <a href="javascript:void(0);" onclick="admin_edit(\'详情\',\'/Finance/FinanceReturnDetails\',' + full.id + ',500,600)"  title="详情">详情</a> ';
                            //return ' <a href = "/Order/GoodsOrder/' + full.order_id + '" target="_blank" class="btn btn-default"  title="详情">订单详情</a> ';
                        }
                    }
                ]
            });
        }

        /*增加*/
        function admin_add(title, url, w, h) {
            layer_show(title, url, "", w, h);
        };

        /*编辑*/
        function admin_edit(title, url, id, w, h) {
            layer_show(title, url, id, w, h);
        };
    </script>
}
